/**
 * 两个数的最大公约数
 * 使用辗转相除法
 * */

var max1 = function(a, b)
{
    var tmp = 0;

    //使a大于b
    if(a < b)
    {
        tmp = a;
        a = b;
        b = tmp;
    }

    while (a%b != 0)
    {
        a = a%b;
        if(a < b)
        {
            tmp = a;
            a = b;
            b = tmp;
        }
    }

    return b;
}

var a = 315;
var b = 819;

var res = max1(a, b);
console.log(res);

